<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增广告 - 广告')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-video-add" >

        <div class="form-group">
            <label class="col-sm-3 control-label">文件原名称：</label>
            <div class="col-sm-8">
                <input name="title" class="form-control" type="text" required>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <h4 class="form-header h4">上传视频</h4>
                    <div class="file-loading">

                        <input id="filePath" class="file" type="file" multiple data-min-file-count="1" data-theme="fas" >
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">加入时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="addtime" class="form-control" placeholder="yyyy-MM-dd" type="date" required>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">区域ID：</label>
            <div class="col-sm-8">
                <input name="areaId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否已注入CDN 0未1已：</label>
            <div class="col-sm-8">
                <div class="radio-box">
                    <input type="radio" name="status" value="">
                    <label th:for="status" th:text="未知"></label>
                </div>
                &lt;!&ndash; <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>&ndash;&gt;
            </div>
        </div>
        <div class="row">
            <label class="col-sm-3 control-label">文件格式：</label>
            <div class="col-sm-8">
                <input name="extension" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">审核  0未1已：</label>
            <div class="col-sm-8">
                <input name="checked" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">上传者ID：</label>
            <div class="col-sm-8">
                <input name="adminId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">点播源ID：</label>
            <div class="col-sm-8">
                <input name="thirdId" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">第三方源：</label>
            <div class="col-sm-8">
                <input name="thirdSource" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">时长，：</label>
            <div class="col-sm-8">
                <input name="duration" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">视频封面：</label>
            <div class="col-sm-8">
                <textarea name="videoImg" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script type="text/javascript">
    var prefix = ctx + "system/video"
    $("#filePath").css("height","200px");
    //文件上传
    function uploadFile() {
        var form = $("#form-video-add")[0];
        var formData = new FormData(form);
        /*formData.append('file', files[0]);*/
        if ($('#filePath')[0].files[0] == null){
            $.modal.alertWarning("请先选择文件路径");
            return false;
        }
        formData.append('file',$('#filePath')[0].files[0]);
        $.ajax({
            url: prefix + "/add",
            type: 'post',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function(result) {
                console.log(result)
                setTimeout(function(){
                    $.modal.close();
                },300);
                var parent = window.parent;
                parent.$.modal.msgSuccess("操作成功!");
                parent.$.table.refresh();
            }
        });
    }

    //表单校验
    $("#form-info-add").validate({
        focusCleanup: true
    });

    //表单提交
    function submitHandler() {
        if ($.validate.form()) {
            uploadFile();
        }
    }

    function adpost() {
        var url=prefix+"/addadpos";
        $.modal.open("查看通知公告",url,'900','600');//900页面宽度  600页面高度
        //$.modal.open弹出框打开
    }
</script>
</body>
</html>